package net.lanelife.casino.caipiao.dto.admin;

import java.util.List;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.persistence.criteria.Selection;

import net.lanelife.casino.caipiao.entity.User;
import net.lanelife.casino.caipiao.entity.User_;
import net.lanelife.casino.common.dto.support.GenericTable;
import net.lanelife.casino.common.entity.json.serialize.CurrencySerializer;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.google.common.collect.Lists;

/**
 * @author Lane
 * 
 * 用户表格
 *
 * @param <DTO>
 */
public class UserTable<DTO> extends GenericTable<DTO, User> {

	private static final long serialVersionUID = 3623285357667360579L;

	@JsonSerialize(using = CurrencySerializer.class)
	private Double accountBalance;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double frozenBalance;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double agBalance;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double bbBalance;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double betTotal;
	
	private Long betTimes;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double winTotal;
	
	private Long winTimes;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double rechargeTotal;
	
	private Long rechargeTimes;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double withdrawTotal;
	
	private Long withdrawTimes;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double transferInTotal;
	
	private Long transferInTimes;
	
	@JsonSerialize(using = CurrencySerializer.class)
	private Double transferOutTotal;
	
	private Long transferOutTimes;
	
	public UserTable() {}
	
	public UserTable(Double accountBalance, Double frozenBalance,
			Double agBalance, Double bbBalance, Double betTotal,
			Long betTimes, Double winTotal, Long winTimes,
			Double rechargeTotal, Long rechargeTimes, Double withdrawTotal,
			Long withdrawTimes, Double transferInTotal,
			Long transferInTimes, Double transferOutTotal,
			Long transferOutTimes) {
		super();
		this.accountBalance = accountBalance;
		this.frozenBalance = frozenBalance;
		this.agBalance = agBalance;
		this.bbBalance = bbBalance;
		this.betTotal = betTotal;
		this.betTimes = betTimes;
		this.winTotal = winTotal;
		this.winTimes = winTimes;
		this.rechargeTotal = rechargeTotal;
		this.rechargeTimes = rechargeTimes;
		this.withdrawTotal = withdrawTotal;
		this.withdrawTimes = withdrawTimes;
		this.transferInTotal = transferInTotal;
		this.transferInTimes = transferInTimes;
		this.transferOutTotal = transferOutTotal;
		this.transferOutTimes = transferOutTimes;
	}
	
	@Override
	public List<Selection<?>> buildExpression(Root<User> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
		List<Selection<?>> columns = Lists.newArrayList();
		columns.add(builder.sum(root.get(User_.accountBalance)));
		columns.add(builder.sum(root.get(User_.frozenBalance)));
		columns.add(builder.sum(root.get(User_.agBalance)));
		columns.add(builder.sum(root.get(User_.bbBalance)));
		columns.add(builder.sum(root.get(User_.betTotal)));
		columns.add(builder.sum(root.get(User_.betTimes)));
		columns.add(builder.sum(root.get(User_.winTotal)));
		columns.add(builder.sum(root.get(User_.winTimes)));
		columns.add(builder.sum(root.get(User_.rechargeTotal)));
		columns.add(builder.sum(root.get(User_.rechargeTimes)));
		columns.add(builder.sum(root.get(User_.withdrawTotal)));
		columns.add(builder.sum(root.get(User_.withdrawTimes)));
		columns.add(builder.sum(root.get(User_.transferInTotal)));
		columns.add(builder.sum(root.get(User_.transferInTimes)));
		columns.add(builder.sum(root.get(User_.transferOutTotal)));
		columns.add(builder.sum(root.get(User_.transferOutTimes)));
		return columns;
	}

	public Double getAccountBalance() {
		return accountBalance;
	}

	public void setAccountBalance(Double accountBalance) {
		this.accountBalance = accountBalance;
	}

	public Double getFrozenBalance() {
		return frozenBalance;
	}

	public void setFrozenBalance(Double frozenBalance) {
		this.frozenBalance = frozenBalance;
	}

	public Double getAgBalance() {
		return agBalance;
	}

	public void setAgBalance(Double agBalance) {
		this.agBalance = agBalance;
	}

	public Double getBbBalance() {
		return bbBalance;
	}

	public void setBbBalance(Double bbBalance) {
		this.bbBalance = bbBalance;
	}

	public Double getBetTotal() {
		return betTotal;
	}

	public void setBetTotal(Double betTotal) {
		this.betTotal = betTotal;
	}

	public Long getBetTimes() {
		return betTimes;
	}

	public void setBetTimes(Long betTimes) {
		this.betTimes = betTimes;
	}

	public Double getWinTotal() {
		return winTotal;
	}

	public void setWinTotal(Double winTotal) {
		this.winTotal = winTotal;
	}

	public Long getWinTimes() {
		return winTimes;
	}

	public void setWinTimes(Long winTimes) {
		this.winTimes = winTimes;
	}

	public Double getRechargeTotal() {
		return rechargeTotal;
	}

	public void setRechargeTotal(Double rechargeTotal) {
		this.rechargeTotal = rechargeTotal;
	}

	public Long getRechargeTimes() {
		return rechargeTimes;
	}

	public void setRechargeTimes(Long rechargeTimes) {
		this.rechargeTimes = rechargeTimes;
	}

	public Double getWithdrawTotal() {
		return withdrawTotal;
	}

	public void setWithdrawTotal(Double withdrawTotal) {
		this.withdrawTotal = withdrawTotal;
	}

	public Long getWithdrawTimes() {
		return withdrawTimes;
	}

	public void setWithdrawTimes(Long withdrawTimes) {
		this.withdrawTimes = withdrawTimes;
	}

	public Double getTransferInTotal() {
		return transferInTotal;
	}

	public void setTransferInTotal(Double transferInTotal) {
		this.transferInTotal = transferInTotal;
	}

	public Long getTransferInTimes() {
		return transferInTimes;
	}

	public void setTransferInTimes(Long transferInTimes) {
		this.transferInTimes = transferInTimes;
	}

	public Double getTransferOutTotal() {
		return transferOutTotal;
	}

	public void setTransferOutTotal(Double transferOutTotal) {
		this.transferOutTotal = transferOutTotal;
	}

	public Long getTransferOutTimes() {
		return transferOutTimes;
	}

	public void setTransferOutTimes(Long transferOutTimes) {
		this.transferOutTimes = transferOutTimes;
	}

}
